
<h1><span class="yiyi-st" id="yiyi-12">numpy.fabs</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.fabs.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.fabs.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="data">
<dt id="numpy.fabs"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">fabs</code><span class="sig-paren">(</span><em>x</em><span class="optional">[</span>, <em>out</em><span class="optional">]</span><span class="sig-paren">)</span><em class="property"> = &lt;ufunc &apos;fabs&apos;&gt;</em></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">按元素计算绝对值。</span></p>
<p><span class="yiyi-st" id="yiyi-15">此函数返回<em class="xref py py-obj">x</em>中数据的绝对值（正幅度）。</span><span class="yiyi-st" id="yiyi-16">不处理复杂值，使用<a class="reference internal" href="numpy.absolute.html#numpy.absolute" title="numpy.absolute"><code class="xref py py-obj docutils literal"><span class="pre">absolute</span></code></a>查找复杂数据的绝对值。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-17">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-18"><strong>x</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-19">需要绝对值的数字的数组。</span><span class="yiyi-st" id="yiyi-20">如果<em class="xref py py-obj">x</em>是标量，则结果<em class="xref py py-obj">y</em>也将是标量。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-21"><strong>out</strong>：ndarray，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-22">数组，其中放置输出。</span><span class="yiyi-st" id="yiyi-23">它的类型被保留，并且它必须是保持输出的正确形状。</span><span class="yiyi-st" id="yiyi-24">请参阅doc.ufuncs。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-25">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-26"><strong>y</strong>：ndarray或scalar</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-27"><em class="xref py py-obj">x</em>的绝对值，返回值始终为浮点型。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-28">也可以看看</span></p>
<dl class="last docutils">
<dt><span class="yiyi-st" id="yiyi-29"><a class="reference internal" href="numpy.absolute.html#numpy.absolute" title="numpy.absolute"><code class="xref py py-obj docutils literal"><span class="pre">absolute</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-30">绝对值，包括<a class="reference external" href="https://docs.python.org/dev/library/functions.html#complex" title="(in Python v3.7)"><code class="xref py py-obj docutils literal"><span class="pre">complex</span></code></a>类型。</span></dd>
</dl>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-31">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">fabs</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="go">1.0</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">fabs</span><span class="p">([</span><span class="o">-</span><span class="mf">1.2</span><span class="p">,</span> <span class="mf">1.2</span><span class="p">])</span>
<span class="go">array([ 1.2,  1.2])</span>
</pre></div>
</div>
</dd></dl>
